class Solution(object):
    def maxDepthAfterSplit(self, seq):
        st1 = 0
        st2 = 0
        n = len(seq)
        out = [0] * n
        for i in range(n):
            if seq[i] == '(':
                if st1 > st2:
                    st2 += 1
                    out[i] = 1
                else:
                    st1 += 1
                    out[i] = 0
            else:
                if st1 > st2:
                    st1 -= 1
                    out[i] = 0
                else:
                    st2 -= 1
                    out[i] = 1
        return out
